package com.demo.java.OD1_50.OD6;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

/**
 * @author bug菌
 * @Source 公众号：猿圈奇妙屋
 * @des： 分班问题
 * @url： https://blog.csdn.net/weixin_43970743/article/details/145502451
 */
public class OdMain {
    public static void main(String[] args) {
        try (Scanner s = new Scanner(System.in)) {
            String[] lines = s.nextLine().split(" ");
            List<Integer> myListOne = new ArrayList<>();
            List<Integer> myListTwo = new ArrayList<>();
            // 0号1班，剩下2班
            int value = 1;
            for (int i = 0; i < lines.length; i++) {
                String[] num = lines[i].split("/");
                int numValue = Integer.parseInt(num[0]);
                if (0 == i) {
                    myListOne.add(numValue);
                    value = 1;
                    continue;
                }
                if (value == 1) {
                    if ("Y".equals(num[1])) {
                        myListOne.add(numValue);
                    } else {
                        myListTwo.add(numValue);
                        value = 2;
                    }
                } else { // value == 2
                    if ("Y".equals(num[1])) {
                        myListTwo.add(numValue);
                    } else {
                        myListOne.add(numValue);
                        value = 1;
                    }
                }
            }
            Collections.sort(myListOne);
            Collections.sort(myListTwo);
            // 打印班级1的学生
            myListOne.forEach(num -> System.out.print(num + " "));
            System.out.println();
            // 打印班级2的学生
            myListTwo.forEach(num -> System.out.print(num + " "));
        } catch (Exception e) {
            System.out.println("发生错误: " + e.getMessage());
        }
    }
}
